package com.thomas.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**   
* @Description: TODO(用一句话描述该文件做什么) 
* @author thomas_liu  
* @date 2018年4月30日 上午10:58:46 
* @version V1.0   
*/
public class TestListNoSort {
	
	public static List<Student> getListStudents(){
		
		List<Student> listStudents = new ArrayList<Student>();
		
		Student stu2 = new Student();
		stu2.setStuName("stu2");
		stu2.setScore(70);
		
		Student stu1 = new Student();
		stu1.setStuName("stu1");
		stu1.setScore(50);
		
		Student stu3 = new Student();
		stu3.setStuName("stu3");
		stu3.setScore(90);
		
		listStudents.add(stu2);
		listStudents.add(stu1);
		listStudents.add(stu3);
		
		return listStudents;
	}
	
	public static void printStuListName(List<Student> list){
		for(int i =0; i< list.size(); i++){
			System.out.println(list.get(i).getStuName());
		}
	}
	
	public static void main(String[] args) {
		List<Student> listStudents = getListStudents();
		
		printStuListName(listStudents); 
		System.out.println("------------");
		
		
		Collections.sort(listStudents, new Comparator<Student>(){

			public int compare(Student o1, Student o2) {
				return String.valueOf(o1.getScore()).compareTo(String.valueOf(o2.getScore()));
			}
			
		}); 
		printStuListName(listStudents);
	}
	
}
